package com.mrd.gtimp.business.repository;

import com.mrd.gtimp.business.entity.DeclarationModel;
import com.mrd.spring.repository.BaseRepository;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface DeclarationModelDao extends BaseRepository<DeclarationModel, String> {
    /**
     * 根据busienssId和type
     * @param bizId
     * @param bizType
     * @return
     */
    DeclarationModel findByBusinessIdAndType(String bizId, String bizType);
    /**
     * 根据busienssId和type
     * @param bizId
     * @return
     */
    DeclarationModel findByBusinessId(String bizId);

    /**
     * 通过modelName查询模板数量
     * @param modelName 模板名称
     */
    @Query("select count(1) from T_BIZ_DECLARATION_MODEL t where t.model_name = ?")
    Integer countByModel_name(String modelName);

    /**
     * 通过modelName查询模板
     * @param modelName 模板名称
     */
    @Query("from T_BIZ_DECLARATION_MODEL t where t.model_name = ?")
    DeclarationModel findByModel_name(String modelName);
}
